-----------------------------------------------------------------------------
--
-- Module      :  Data.Units.SI
-- Copyright   :
-- License     :  AllRightsReserved
--
-- Maintainer  :  Eduard Sergeev
-- Stability   :
-- Portability :
--
--  International System of Units (SI) definition
--
-----------------------------------------------------------------------------
{-# LANGUAGE NoImplicitPrelude, TemplateHaskell, QuasiQuotes, TypeFamilies, TypeOperators,
UndecidableInstances, FlexibleInstances #-}


module Data.Units.SI where

import Prelude (Show(show), Num, Fractional)
import qualified Prelude as P
import Data.Function
import Data.Units.Generator
import Data.Units.Instances

-- ToBe removed
import Data.TypeLevel.Families ((:<=:))
import Data.Units.Types
--

-- * Base units

-- | Metre (M)
[unit| M(meters)_m<m>:1 |]

-- | Kilogram (Kg)
[unit| Kg(kilograms)_kg<kg>:2 |]

-- | Second (S)
[unit| S(seconds)_s<s>:3 |]

-- | Ampere (A)
[unit| A(amperes)_A<A>:4 |]

-- | Kelvin (K)
[unit| K(kelvins)_K<K>:5 |]

-- | Mole (Mol)
[unit| Mol(moles)_mol<mol>:6 |]

-- | Candela (Cd)
[unit| Cd(candelas)_cd<cd>:7 |]


-- * Derived units

-- | Hertz (Hz)
[unit| Hz(toHertz)_Hz = 1/S |]

-- | Newton (N)
[unit| N(newtons)_N = Kg*M/S^2 |]

-- | Pascal (Pa)
[unit| Pa(pascals)_Pa = N/M^2 |]

-- | Joule (J)
[unit| J(joules)_J = N*M |]

-- | Watt (W)
[unit| W(watts)_W = J/S |]

-- | Volt (V)
[unit| V(volts)_V = W/A |]
--[unit| V(volts)_V = (Kg*M*M)/(S*S*S*A) |]

-- | Ohm (Om)
--[unit| Om(ohms)_O = V/A |]
[unit| Ω(ohms)_Ω = V/A |]


-- | Coulomb (C)
[unit| C(coulombs)_C = S*A |]

-- | Farad (F)
[unit| F(farads)_F = C/V |]

-- | Radian (Rad)
[unit| Rad(radians)_Rad = M/M |]



-- * Prefixes
mili :: (Fractional n) => n ::: u -> n ::: u
mili (Q n) = Q (n P./ 1000)

centi :: (Fractional n) => n ::: u -> n ::: u
centi (Q n) = Q (n P./ 100)

kilo :: (Num n) => n ::: u -> n ::: u
kilo (Q n) = Q (1000 P.* n)
